package com.one.consumer.reserve.ui.binder;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;

import com.one.common.manager.imageloader.ILoader;
import com.one.common.manager.imageloader.LoaderManager;
import com.one.common.model.http.NetConstant;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;
import com.one.consumer.R;
import com.one.consumer.reserve.model.item.ProgramItem;
import com.one.consumer.reserve.model.item.ProjectTypeItem;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/21 下午10:12
 * description ：户型选择
 **/
public class ProjectTypeBinder extends BaseItemBinder<ProjectTypeItem> {
    public ProjectTypeBinder(OnProjectTypeClick onProjectTypeClick) {
        super(R.layout.item_case);
        this.onProjectTypeClick = onProjectTypeClick;
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull ProjectTypeItem item) {
        ImageView imageView = holder.getView(R.id.iv_bg);
        ILoader.Options options = ILoader.Options.roundOptions(8);
        options.setCenterCrop(true);
        options.setBlur(true);
        LoaderManager.getLoader().loadNet(imageView, NetConstant.IMG_HOST + item.getHuxing_img(),
                options);
        holder.setText(R.id.tv_name, item.getHuxing_name());
        holder.getView(R.id.rl_case).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(onProjectTypeClick !=null){
                    onProjectTypeClick.typeClick(item);
                }
            }
        });
    }

    private OnProjectTypeClick onProjectTypeClick;

    public OnProjectTypeClick getOnProjectTypeClick() {
        return onProjectTypeClick;
    }

    public void setOnProjectTypeClick(OnProjectTypeClick onProjectTypeClick) {
        this.onProjectTypeClick = onProjectTypeClick;
    }

    public interface OnProjectTypeClick{
        void typeClick(ProjectTypeItem item);
    }
}
